//
//	LocalModel.m
//	Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport



#import "LocalModel.h"

NSString *const kLocalModelAttachment = @"attachment";
NSString *const kLocalModelAuthor = @"author";
NSString *const kLocalModelAvatarstatus = @"avatarstatus";
NSString *const kLocalModelDate = @"date";
NSString *const kLocalModelDateline = @"dateline";
NSString *const kLocalModelFid = @"fid";
NSString *const kLocalModelFromType = @"from_type";
NSString *const kLocalModelHeadimg = @"headimg";
NSString *const kLocalModelLevel = @"level";
NSString *const kLocalModelMessage = @"message";
NSString *const kLocalModelNewField = @"new";
NSString *const kLocalModelPic = @"pic";
NSString *const kLocalModelPid = @"pid";
NSString *const kLocalModelPllist = @"pllist";
NSString *const kLocalModelSubject = @"subject";
NSString *const kLocalModelTag = @"tag";
NSString *const kLocalModelTags = @"tags";
NSString *const kLocalModelThumb = @"thumb";
NSString *const kLocalModelTid = @"tid";
NSString *const kLocalModelUid = @"uid";
NSString *const kLocalModelViews = @"views";
NSString *const kLocalModelZanlist = @"zanlist";

@interface LocalModel ()
@end
@implementation LocalModel




/**
 * Instantiate the instance using the passed dictionary values to set the properties values
 */

-(instancetype)initWithDictionary:(NSDictionary *)dictionary
{
	self = [super init];
	if(![dictionary[kLocalModelAttachment] isKindOfClass:[NSNull class]]){
		self.attachment = [dictionary[kLocalModelAttachment] integerValue];
	}

	if(![dictionary[kLocalModelAuthor] isKindOfClass:[NSNull class]]){
		self.author = dictionary[kLocalModelAuthor];
	}	
	if(![dictionary[kLocalModelAvatarstatus] isKindOfClass:[NSNull class]]){
		self.avatarstatus = [dictionary[kLocalModelAvatarstatus] integerValue];
	}

	if(![dictionary[kLocalModelDate] isKindOfClass:[NSNull class]]){
		self.date = dictionary[kLocalModelDate];
	}	
	if(![dictionary[kLocalModelDateline] isKindOfClass:[NSNull class]]){
		self.dateline = [dictionary[kLocalModelDateline] integerValue];
	}

	if(![dictionary[kLocalModelFid] isKindOfClass:[NSNull class]]){
		self.fid = [dictionary[kLocalModelFid] integerValue];
	}

	if(![dictionary[kLocalModelFromType] isKindOfClass:[NSNull class]]){
		self.fromType = [dictionary[kLocalModelFromType] integerValue];
	}

	if(![dictionary[kLocalModelHeadimg] isKindOfClass:[NSNull class]]){
		self.headimg = dictionary[kLocalModelHeadimg];
	}	
	if(![dictionary[kLocalModelLevel] isKindOfClass:[NSNull class]]){
		self.level = [dictionary[kLocalModelLevel] integerValue];
	}

	if(![dictionary[kLocalModelMessage] isKindOfClass:[NSNull class]]){
		self.message = dictionary[kLocalModelMessage];
	}	
	if(![dictionary[kLocalModelNewField] isKindOfClass:[NSNull class]]){
		self.newField = [dictionary[kLocalModelNewField] integerValue];
	}

	if(![dictionary[kLocalModelPic] isKindOfClass:[NSNull class]]){
		self.pic = dictionary[kLocalModelPic];
	}	
	if(![dictionary[kLocalModelPid] isKindOfClass:[NSNull class]]){
		self.pid = [dictionary[kLocalModelPid] integerValue];
	}

	if(![dictionary[kLocalModelPllist] isKindOfClass:[NSNull class]]){
		self.pllist = dictionary[kLocalModelPllist];
	}	
	if(![dictionary[kLocalModelSubject] isKindOfClass:[NSNull class]]){
		self.subject = dictionary[kLocalModelSubject];
	}	
	if(dictionary[kLocalModelTag] != nil && [dictionary[kLocalModelTag] isKindOfClass:[NSArray class]]){
		NSArray * tagDictionaries = dictionary[kLocalModelTag];
		NSMutableArray * tagItems = [NSMutableArray array];
		for(NSDictionary * tagDictionary in tagDictionaries){
			Tag * tagItem = [[Tag alloc] initWithDictionary:tagDictionary];
			[tagItems addObject:tagItem];
		}
		self.tag = tagItems;
	}
	if(![dictionary[kLocalModelTags] isKindOfClass:[NSNull class]]){
		self.tags = dictionary[kLocalModelTags];
	}	
	if(![dictionary[kLocalModelThumb] isKindOfClass:[NSNull class]]){
		self.thumb = dictionary[kLocalModelThumb];
	}	
	if(![dictionary[kLocalModelTid] isKindOfClass:[NSNull class]]){
		self.tid = [dictionary[kLocalModelTid] integerValue];
	}

	if(![dictionary[kLocalModelUid] isKindOfClass:[NSNull class]]){
		self.uid = [dictionary[kLocalModelUid] integerValue];
	}

	if(![dictionary[kLocalModelViews] isKindOfClass:[NSNull class]]){
		self.views = [dictionary[kLocalModelViews] integerValue];
	}

	if(![dictionary[kLocalModelZanlist] isKindOfClass:[NSNull class]]){
		self.zanlist = dictionary[kLocalModelZanlist];
	}	
	return self;
}


/**
 * Returns all the available property values in the form of NSDictionary object where the key is the approperiate json key and the value is the value of the corresponding property
 */
-(NSDictionary *)toDictionary
{
	NSMutableDictionary * dictionary = [NSMutableDictionary dictionary];
	dictionary[kLocalModelAttachment] = @(self.attachment);
	if(self.author != nil){
		dictionary[kLocalModelAuthor] = self.author;
	}
	dictionary[kLocalModelAvatarstatus] = @(self.avatarstatus);
	if(self.date != nil){
		dictionary[kLocalModelDate] = self.date;
	}
	dictionary[kLocalModelDateline] = @(self.dateline);
	dictionary[kLocalModelFid] = @(self.fid);
	dictionary[kLocalModelFromType] = @(self.fromType);
	if(self.headimg != nil){
		dictionary[kLocalModelHeadimg] = self.headimg;
	}
	dictionary[kLocalModelLevel] = @(self.level);
	if(self.message != nil){
		dictionary[kLocalModelMessage] = self.message;
	}
	dictionary[kLocalModelNewField] = @(self.newField);
	if(self.pic != nil){
		dictionary[kLocalModelPic] = self.pic;
	}
	dictionary[kLocalModelPid] = @(self.pid);
	if(self.pllist != nil){
		dictionary[kLocalModelPllist] = self.pllist;
	}
	if(self.subject != nil){
		dictionary[kLocalModelSubject] = self.subject;
	}
	if(self.tag != nil){
		NSMutableArray * dictionaryElements = [NSMutableArray array];
		for(Tag * tagElement in self.tag){
			[dictionaryElements addObject:[tagElement toDictionary]];
		}
		dictionary[kLocalModelTag] = dictionaryElements;
	}
	if(self.tags != nil){
		dictionary[kLocalModelTags] = self.tags;
	}
	if(self.thumb != nil){
		dictionary[kLocalModelThumb] = self.thumb;
	}
	dictionary[kLocalModelTid] = @(self.tid);
	dictionary[kLocalModelUid] = @(self.uid);
	dictionary[kLocalModelViews] = @(self.views);
	if(self.zanlist != nil){
		dictionary[kLocalModelZanlist] = self.zanlist;
	}
	return dictionary;

}

/**
 * Implementation of NSCoding encoding method
 */
/**
 * Returns all the available property values in the form of NSDictionary object where the key is the approperiate json key and the value is the value of the corresponding property
 */
- (void)encodeWithCoder:(NSCoder *)aCoder
{
	[aCoder encodeObject:@(self.attachment) forKey:kLocalModelAttachment];	if(self.author != nil){
		[aCoder encodeObject:self.author forKey:kLocalModelAuthor];
	}
	[aCoder encodeObject:@(self.avatarstatus) forKey:kLocalModelAvatarstatus];	if(self.date != nil){
		[aCoder encodeObject:self.date forKey:kLocalModelDate];
	}
	[aCoder encodeObject:@(self.dateline) forKey:kLocalModelDateline];	[aCoder encodeObject:@(self.fid) forKey:kLocalModelFid];	[aCoder encodeObject:@(self.fromType) forKey:kLocalModelFromType];	if(self.headimg != nil){
		[aCoder encodeObject:self.headimg forKey:kLocalModelHeadimg];
	}
	[aCoder encodeObject:@(self.level) forKey:kLocalModelLevel];	if(self.message != nil){
		[aCoder encodeObject:self.message forKey:kLocalModelMessage];
	}
	[aCoder encodeObject:@(self.newField) forKey:kLocalModelNewField];	if(self.pic != nil){
		[aCoder encodeObject:self.pic forKey:kLocalModelPic];
	}
	[aCoder encodeObject:@(self.pid) forKey:kLocalModelPid];	if(self.pllist != nil){
		[aCoder encodeObject:self.pllist forKey:kLocalModelPllist];
	}
	if(self.subject != nil){
		[aCoder encodeObject:self.subject forKey:kLocalModelSubject];
	}
	if(self.tag != nil){
		[aCoder encodeObject:self.tag forKey:kLocalModelTag];
	}
	if(self.tags != nil){
		[aCoder encodeObject:self.tags forKey:kLocalModelTags];
	}
	if(self.thumb != nil){
		[aCoder encodeObject:self.thumb forKey:kLocalModelThumb];
	}
	[aCoder encodeObject:@(self.tid) forKey:kLocalModelTid];	[aCoder encodeObject:@(self.uid) forKey:kLocalModelUid];	[aCoder encodeObject:@(self.views) forKey:kLocalModelViews];	if(self.zanlist != nil){
		[aCoder encodeObject:self.zanlist forKey:kLocalModelZanlist];
	}

}

/**
 * Implementation of NSCoding initWithCoder: method
 */
- (instancetype)initWithCoder:(NSCoder *)aDecoder
{
	self = [super init];
	self.attachment = [[aDecoder decodeObjectForKey:kLocalModelAttachment] integerValue];
	self.author = [aDecoder decodeObjectForKey:kLocalModelAuthor];
	self.avatarstatus = [[aDecoder decodeObjectForKey:kLocalModelAvatarstatus] integerValue];
	self.date = [aDecoder decodeObjectForKey:kLocalModelDate];
	self.dateline = [[aDecoder decodeObjectForKey:kLocalModelDateline] integerValue];
	self.fid = [[aDecoder decodeObjectForKey:kLocalModelFid] integerValue];
	self.fromType = [[aDecoder decodeObjectForKey:kLocalModelFromType] integerValue];
	self.headimg = [aDecoder decodeObjectForKey:kLocalModelHeadimg];
	self.level = [[aDecoder decodeObjectForKey:kLocalModelLevel] integerValue];
	self.message = [aDecoder decodeObjectForKey:kLocalModelMessage];
	self.newField = [[aDecoder decodeObjectForKey:kLocalModelNewField] integerValue];
	self.pic = [aDecoder decodeObjectForKey:kLocalModelPic];
	self.pid = [[aDecoder decodeObjectForKey:kLocalModelPid] integerValue];
	self.pllist = [aDecoder decodeObjectForKey:kLocalModelPllist];
	self.subject = [aDecoder decodeObjectForKey:kLocalModelSubject];
	self.tag = [aDecoder decodeObjectForKey:kLocalModelTag];
	self.tags = [aDecoder decodeObjectForKey:kLocalModelTags];
	self.thumb = [aDecoder decodeObjectForKey:kLocalModelThumb];
	self.tid = [[aDecoder decodeObjectForKey:kLocalModelTid] integerValue];
	self.uid = [[aDecoder decodeObjectForKey:kLocalModelUid] integerValue];
	self.views = [[aDecoder decodeObjectForKey:kLocalModelViews] integerValue];
	self.zanlist = [aDecoder decodeObjectForKey:kLocalModelZanlist];
	return self;

}

/**
 * Implementation of NSCopying copyWithZone: method
 */
- (instancetype)copyWithZone:(NSZone *)zone
{
	LocalModel *copy = [LocalModel new];

	copy.attachment = self.attachment;
	copy.author = [self.author copy];
	copy.avatarstatus = self.avatarstatus;
	copy.date = [self.date copy];
	copy.dateline = self.dateline;
	copy.fid = self.fid;
	copy.fromType = self.fromType;
	copy.headimg = [self.headimg copy];
	copy.level = self.level;
	copy.message = [self.message copy];
	copy.newField = self.newField;
	copy.pic = [self.pic copy];
	copy.pid = self.pid;
	copy.pllist = [self.pllist copy];
	copy.subject = [self.subject copy];
	copy.tag = [self.tag copy];
	copy.tags = [self.tags copy];
	copy.thumb = [self.thumb copy];
	copy.tid = self.tid;
	copy.uid = self.uid;
	copy.views = self.views;
	copy.zanlist = [self.zanlist copy];

	return copy;
}
@end